import request from '@/utils/request';

/**
 * 分页查询销售单子表
 */
export async function pageSellSon(params) {
  const res = await request.get('/store/sellSon/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询销售单子表列表
 */
export async function listSellSon(params) {
  const res = await request.get('/store/sellSon', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询销售单子表
 */
export async function getSellSon(id) {
  const res = await request.get('/store/sellSon/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加销售单子表
 */
export async function addSellSon(data) {
  const res = await request.post('/store/sellSon', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改销售单子表
 */
export async function updateSellSon(data) {
  const res = await request.put('/store/sellSon', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除销售单子表
 */
export async function removeSellSon(data) {
  const res = await request.put('/store/sellSon/remove',  data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
